package com.witsight.hibernate.util;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**   
 * 说明：sql构建器
 * @Title: SqlBuilder.java 
 * @Package com.witsight.hibernate.util 
 * @See: {@link SqlBuilder}
 * Copyright: Copyright (c) 2017
 * Company:sany huax witsight team by product
 * @author: fuyp  
 * @date: 2017年9月14日 下午3:48:30 
 * @version: V1.0
 *
 */
public class SqlBuilder {
	/**
     * Logger
     */
    private static final Logger log = LoggerFactory.getLogger(SqlBuilder.class);

    /**
     * @param sql
     * @param params
     * @return
     */
    public static String parse(String sql, Map<String, ?> params) {
        if (params == null) return sql;

        String statement = TextTemplates.replaceTemplate(sql, params);
        statement = TextTemplates.removeOptionalFrag(statement, params);
        if (log.isDebugEnabled()) {
            log.debug("run sql : " + statement);
        }
        return statement;  //To change body of created methods use File | Settings | File Templates.
    }
}
